home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / intl.sit / Almanac_1.53b1_intl_patch.bin / Almanac 1.53b1 intl patch
Encoding:
Text File  |  1989-06-08  |  9.2 KB  |  349 lines  |  [TEXT/EDIT]

  1. on openStack
  2.   global force,intl -- intl
  3.   put 0 into force
  4.   hide message box
  5.   put the seconds/86400 + 16480.5 + 5/24 into jd2
  6.   put trunc(jd2+24000000) +1 into jd
  7.   get the date
  8.   -- intl to next widget
  9.   if it contains "."
  10.   then put true into intl
  11.   else put false into intl
  12.   convert it to dateItems
  13.   if intl then
  14.     repeat with i=1 to number of chars of it
  15.       if char i of it = "." then put "," into char i of it
  16.     end repeat
  17.     put item 1 of it into d
  18.     put item 2 of it into m
  19.   else
  20.     put item 2 of it into m
  21.     put item 3 of it into d
  22.   end if
  23.   -- intl
  24.   put false into val
  25.   if m>4 and m<=10 then put true into val
  26.   put trunc(jd-7*trunc(jd/7)) into w
  27.   -- -1 added to correct for 1989 v. 1.53
  28.   if m=4 and d>=w-1 then put true into val
  29.   if m=10 and (d-w)>=25 then put false into val
  30.   -- for v. 1.53...
  31.   set hilite of bkgnd button "DST" to val
  32.   if val then
  33.     put "D" into char 3 of last word of cd fld coords of cd 1
  34.   else
  35.     put "S" into char 3 of last word of cd fld coords of cd 1
  36.   end if
  37.   push card
  38.   if the number of this cd is 1 then
  39.     put line 2 of card field "Algol" into ecl
  40.     repeat
  41.       if ecl > jd2 then exit repeat
  42.       add 2.8673075 to ecl
  43.     end repeat
  44.     set numberFormat to "0.0"
  45.     put "Next minimum of Algol occurs in" && (ecl-jd2)*24 &&┬
  46.     "hours at JD=" into line 1 of card field Algol
  47.     set numberFormat to "0.###"
  48.     put ecl+2400000 after line 1 of card field Algol
  49.     put ecl into line 2 of card field Algol
  50.   end if
  51. end openStack
  52.  
  53. function TJDDate
  54.   global intl
  55.   get the seconds
  56.   add 86400+3600*(12+DSTcheck()) to it
  57.   -- intl add global and if below
  58.   convert it to long date
  59.   if intl then
  60.     put char 1 to (offset(".",second word of it)-1) of second word of it ┬
  61.     && third word of it && last word of it into he
  62.   else
  63.     put char 1 to (offset(",",third word of it)-1) of third word of it ┬
  64.     && second word of it && last word of it into he
  65.   end if
  66.   return he
  67. end TJDDate
  68.  
  69. function getDate
  70.   global intl
  71.   get the seconds
  72.   convert it to long date
  73.   -- intl add global and if below
  74.   if intl then
  75.     put char 1 to (offset(".",second word of it)-1) of second word of it ┬
  76.     && third word of it && last word of it into he
  77.   else
  78.     put char 1 to (offset(",",third word of it)-1) of third word of it ┬
  79.     && second word of it && last word of it into he
  80.   end if
  81.   return he
  82. end getDate
  83.  
  84. function getJDDate
  85.   global intl
  86.   get the seconds
  87.   add 3600*(12+DSTcheck()) to it
  88.   convert it to long date
  89.   -- intl add global and if below
  90.   if intl then
  91.     put char 1 to (offset(".",second word of it)-1) of second word of it ┬
  92.     && third word of it && last word of it into he
  93.   else
  94.     put char 1 to (offset(",",third word of it)-1) of third word of it ┬
  95.     && second word of it && last word of it into he
  96.   end if
  97.   return he
  98. end getJDDate
  99.  
  100. function getUTDate
  101.   global intl
  102.   get the seconds
  103.   add 3600*(DSTcheck()) to it
  104.   convert it to long date
  105.   -- intl add global and if below
  106.   if intl then
  107.     put char 1 to (offset(".",second word of it)-1) of second word of it ┬
  108.     && third word of it && last word of it into he
  109.   else
  110.     put char 1 to (offset(",",third word of it)-1) of third word of it ┬
  111.     && second word of it && last word of it into he
  112.   end if
  113.   return he
  114. end getUTDate
  115.  
  116. function DSTcheck
  117.   get first word of line 4 of card field Coords of first cd
  118.   if hilite of bkgnd button "DST"
  119.   then put it-1 into temp
  120.   else put it into temp
  121.   return temp
  122. end DSTcheck
  123.  
  124. function sgn x
  125.   if x<0 then
  126.     get -1
  127.   else if x=0 then
  128.     get 0
  129.   else if x>0 then
  130.     get 1
  131.   end if
  132.   return it
  133. end sgn
  134.  
  135. on dayOfYear
  136.   -- returns day, dayUT as number of day in year
  137.   -- intl fix...
  138.   global dayUT,day,daySecs,intl
  139.   put the date into daysecs
  140.   -- intl add global and if/repeat below
  141.   if intl then
  142.     repeat with i=1 to number of chars of daysecs
  143.       if char i of daysecs = "." then put "/" into char i of daysecs
  144.     end repeat
  145.   end if
  146.   convert daySecs to seconds
  147.   put number of chars of the date into ndate
  148.   put "12/31/" & (char ndate-1 to ndate of the date)-1 into Jan0
  149.   convert Jan0 to seconds
  150.   put (daySecs-Jan0)/86400 into day
  151.   put (daySecs-Jan0+3600*DSTcheck())/86400 into dayUT
  152. end dayOfYear
  153.  
  154. on cheb a,b,c
  155.   global x,xa,xb
  156.   put 2*x*a-b+c into temp
  157.   put a into xb
  158.   put temp into xa
  159. end cheb
  160.  
  161. on UT
  162.   global day,daySecs,x,xa,xb,m
  163.   dayOfYear -- gets daySecs
  164.   get ((the seconds-daySecs)/3600+DSTcheck())mod 24
  165.   put trunc(it) into h
  166.   put trunc(60*(it-h)) into m
  167.   if m<10 then put "0" before m
  168.   put "Universal Time = "& h &":" & m into line 1 of field 1
  169.   put it into line 2 of field 1
  170. end UT
  171.  
  172. on ST
  173.   global day,daySecs,x,xa,xb,dayUT
  174.   dayOfYear -- gets day
  175.   put (dayUT-1)/183-1 into x
  176.   put 0 into a
  177.   put 0 into b
  178.   put 7 into i
  179.   repeat until i=0
  180.     cheb a,b,word i+1 of card field "Sidereal Cheb" of card 1
  181.     put xa into a
  182.     put xb into b
  183.     subtract 1 from i
  184.   end repeat
  185.   put xb into b2
  186.   cheb a,b,word 1 of card field "Sidereal Cheb" of card 1
  187.   get ((xa-b2)/2+((the seconds-daySecs)/3600+DSTcheck())*1.00273791-┬
  188.   (line 2 of card field "coords" of card 1)/15+24) mod 24
  189.   put trunc(it) into h
  190.   put trunc(60*(it-h)) into m
  191.   if m<10 then put "0" before m
  192.   put "Sidereal Time = "& h &":" & m into line 1 of field 2
  193.   put it into line 2 of field 2
  194. end ST
  195.  
  196. on hm decv
  197.   global it,h,m
  198.   put trunc(it) into h
  199.   put trunc(60*(it-h)) into m
  200.   if decv then put abs(m) into m
  201.   if m<10 then put "0" before m
  202. end hm
  203.  
  204. on calc num,force
  205.   set cursor to 1001
  206.   -- calcs ra and dec, force =1 means do it anyway
  207.   put pi/180 into fac
  208.   global day,daySecs,x,xa,xb,dayUT,it,h,m,mode
  209.   dayOfYear -- gets day,dayUT
  210.   get line 3 of field 1
  211.   put fac*(line 1 of card field "Coords" of card 1) into lat
  212.   if (it=trunc(dayUT) and the optionkey is up) and force=0 then
  213.     put line 5 of field 5 into dra
  214.     put (line 6 of field 5)*fac into dec
  215.     put line 3 of field 6 into arg
  216.   else
  217.     set cursor to 1002
  218.     put trunc(dayUT) into line 3 of field 1
  219.     put (dayUT+((the seconds-daySecs)/3600+DSTcheck())/24-1)/183-1 ┬
  220.     into x
  221.     put 0 into a
  222.     put 0 into b
  223.     put num into i
  224.     repeat until i=0
  225.       set cursor to busy
  226.       cheb a,b,word i+1 of field 3
  227.       put xa into a
  228.       put xb into b
  229.       subtract 1 from i
  230.     end repeat
  231.     put xb into b2
  232.     cheb a,b,word 1 of field 3
  233.     get ((xa-b2)/2+48) mod 24
  234.     put it*15 into dra
  235.     put dra into line 5 of field 5
  236.     hm false
  237.     put short name of this card &" R.A. = "& h &"h " & m &"m"into┬
  238.     line 1 of field 5
  239.     put 0 into a
  240.     put 0 into b
  241.     put num into i
  242.     repeat until i=0
  243.       set cursor to busy
  244.       cheb a,b,word i+1 of field 4
  245.       put xa into a
  246.       put xb into b
  247.       subtract 1 from i
  248.     end repeat
  249.     put xb into b2
  250.     cheb a,b,word 1 of field 4
  251.     get (xa-b2)/2
  252.     put it*fac into dec
  253.     put it into line 6 of field 5
  254.     put empty into sign
  255.     if it<0 and it>-1 then put "-" into sign
  256.     if it>0 then put "+" into sign
  257.     hm true
  258.     put short name of this card&" Dec.  = "&sign&h&"í "&m&"'" ┬
  259.     into line 2 of field 5
  260.     
  261.     if "Sun" is in short name of this card then
  262.       get (-.20791-sin(lat)*sin(dec))/(cos(lat)*cos(dec))
  263.       put abs(atan(sqrt(1-it*it)/it)) into ang
  264.       if -.20791<sin(lat)*sin(dec) then put pi-ang into ang
  265.       put ang/fac/15 into delta
  266.       put (dra/15+(line 2 of field 1)-line 2 of field 2+24-DSTcheck()) ┬
  267.       mod 24 into arg
  268.       get arg-delta
  269.       put it into line 3 of card field 1
  270.       hm false
  271.       ampm
  272.       put "Twilight begins at "& h &":" & m && mode into line 1 of┬
  273.       cd fld 1
  274.       get arg+delta
  275.       put it into line 4 of cd fld 1
  276.       hm false
  277.       ampm
  278.       put "Twilight ends    at "& h &":" & m && mode into line 2 of ┬
  279.       cd fld 1
  280.     end if
  281.     get -sin(lat)*sin(dec)/cos(lat)/cos(dec)
  282.     put atan(sqrt(1-it*it)/it) into ang
  283.     if dec>0 then
  284.       add pi to ang
  285.     end if
  286.     put ang/fac/15 into delta
  287.     put dra/15+line 2 of field 1-line 2 of field 2+24-DSTcheck()into arg
  288.     get (arg-delta) mod 24
  289.     put arg into line 3 of field 6
  290.     put it into line 4 of field 6
  291.     hm false
  292.     ampm
  293.     put short name of this card && "Rises at "& h &":" & m && mode ┬
  294.     into line 1 of field 6
  295.     get (arg+delta) mod 24
  296.     put it into line 5 of field 6
  297.     hm false
  298.     ampm
  299.     put short name of this card && "Sets  at "& h &":" & m && mode into ┬
  300.     line 2 of field 6
  301.     
  302.     set cursor to 1001
  303.   end if
  304.   -- calc alt and az of object
  305.   put ((360+15*(line 2 of field 2)-dra) mod 360)*fac into LHA
  306.   put cos(LHA)*sin(lat)-tan(dec)*cos(lat) into den
  307.   get atanq(den,sin(LHA))
  308.   put round(it/fac) into temp
  309.   put sin(lat)*sin(dec)+cos(lat)*cos(dec)*cos(LHA) into sina
  310.   if abs(sina)<1 then
  311.     get round(atan(sina/(sqrt(1-sina*sina)))/fac)
  312.     if it>0 then
  313.       put "Az. = "& temp into line 3 of field 5
  314.       put "Alt. = " & it into line 4 of field 5
  315.     else
  316.       if temp>180
  317.       then put "W" into tem
  318.       else put "E" into tem
  319.       put "below " & tem & " horizon" into line 3 of field 5
  320.       put empty into line 4 of field 5
  321.     end if
  322.   else
  323.     beep
  324.   end if
  325.   set cursor to 1
  326. end calc
  327.  
  328. function atanq x,y
  329.   get atan(y/x)
  330.   if y>0 then add pi to it
  331.   if y/x<0 then add pi to it
  332.   return it
  333. end atanq
  334.  
  335. on ampm
  336.   global h,mode,intl
  337.   if intl then
  338.     put empty into mode
  339.   else
  340.     put h into h2
  341.     if h>11 then
  342.       subtract 12 from h
  343.       put "PM" into mode
  344.     else
  345.       put "AM" into mode
  346.     end if
  347.     if h=0 then put 12 into h
  348.   end if
  349. end ampm